package com.ts.store.config;

import com.ts.store.beans.StorageProperties;
import com.ts.store.beans.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author wanglei
 * on 2020/4/8
 */
@Configuration
@EnableConfigurationProperties(StorageProperties.class)
public class StorageAutoConfigure {
    @Autowired
    private StorageProperties storageProperties;

    @Bean
    @ConditionalOnMissingBean(StorageService.class)
    StorageService storageService() {
        return new StorageService(storageProperties);
    }

}
